/**
 * 
 */
package com.wsj.dao.hibernate;

import java.util.List;

import org.springframework.dao.DataAccessException;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.wsj.dao.IUserBaseDao;
import com.wsj.web.vo.homeSite.UserBase;

/**
 * @author fengbin  createTime:2009-7-5
 * 用户基本信息dao
 */
public class UserBaseDaoImpl  extends HibernateDaoSupport implements IUserBaseDao{

	public UserBase getUserBaseById(long userId) throws DataAccessException {
		
		 Object obj = this.getHibernateTemplate().get(UserBase.class, userId);
		 if(obj!=null){
			 return (UserBase)obj;
		 }
		 
		 return null;
		
	}

	/******
	 * 通过用户名,获取用户对象
	 */
	@SuppressWarnings("unchecked")
	public UserBase getUserBaseByUserName(String userName) throws DataAccessException {
		List<UserBase> li = this.getHibernateTemplate().find("from UserBase u where u.userName = ?",userName);
		if(li!=null  && !li.isEmpty()){
			return  (UserBase)li.get(0);
		}
		
		return null;
	}

}
